package follow.juc.writing.demo1;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

/**
 * @author tu zy
 * @version 1.0
 * @date 2020/11/28 18:07
 */

public class Demo3Callable implements Callable {

    @Override
    public String call() throws Exception {
        return "我是callable方法实现的多线程";
    }

    public static void main(String[] args) throws Exception {
        Demo3Callable callable = new Demo3Callable();
        FutureTask<String> target = new FutureTask<String>(callable);
        new Thread(target).start();

        //这个是直接这个类获取的值
        String call = callable.call();

        //futureTask获取执行的值
        String s = target.get();
        System.out.println(call);
        System.out.println(s+"------");

    }
}
